#pragma once
#include "VC_Drawable.h"
#include "C_Widget.h"
#include "C_TextButton.h"
#include "C_RectButton.h"
#include "C_Label.h"
#include "C_List.h"
#include "C_ShowMessage.h"
#include "C_FusionTable.h"
#include "C_LineEdit.h"
#include "C_FusionTable.h"

typedef struct _ElemAmt
{
	C_ChemicalElement *e;
	int	amt;

	static _ElemAmt make(C_ChemicalElement *_e,int _amt)
	{
		_ElemAmt res;
		res.e = _e;
		res.amt = _amt;
		return res;
	}

	static _ElemAmt* makep(C_ChemicalElement *_e, int _amt)
	{
		_ElemAmt *res = new _ElemAmt();
		res->e = _e;
		res->amt = _amt;
		return res;
	}
} S_ElemAmt;

class C_GUI_FusionEditor :
	public VC_Drawable
{
private:
	C_FusionTable m_fusTable;
	C_Fusion	  *m_fusion;

	C_ShowMessage m_msg;

	gui::C_Widget	m_widget;
	gui::C_Widget	m_wgTables;
	gui::C_List		m_ltElemTable;

	////////////////////////////////////////////////////////
	////	 WIDGET WITH PROPERTIES & AMOUNT
	gui::C_Widget	m_wgPropsAndAmount;

	gui::C_Widget	m_wgPropsAndFusion;
	/////////////////////////////////////////////////////////////////
	//////	PROPERTIES
	gui::C_Widget   m_wgElemProps;
	/////////////////////////////////////////////////////////////////
	/////	FUSION PROPERTIES
	gui::C_Widget   m_wgFusionProps;

	//////////////////////////////////////////////////////////
	/////	Number
	gui::C_Widget	m_wgElemId;
	gui::C_Label	m_lbElemIdTopic;
	gui::C_Label	m_lbElemIdResult;

	//////////////////////////////////////////////////////////
	/////	GLYPH
	gui::C_Widget	m_wgElemGlyph;
	gui::C_Label	m_lbElemGlyphTopic;
	gui::C_Label	m_lbElemGlyphResult;

	//////////////////////////////////////////////////////////
	/////	Name
	gui::C_Widget	m_wgElemName;
	gui::C_Label	m_lbElemNameTopic;
	gui::C_Label	m_lbElemNameResult;

	//////////////////////////////////////////////////////////
	/////	Weight
	gui::C_Widget	m_wgElemWeight;
	gui::C_Label	m_lbElemWeightTopic;
	gui::C_Label	m_lbElemWeightResult;

	//////////////////////////////////////////////////////////
	/////	Appereance
	gui::C_Widget	m_wgElemApp;
	gui::C_Label	m_lbElemAppTopic;
	gui::C_Label	m_lbElemAppResult;

	//////////////////////////////////////////////////////////
	/////	Energy
	gui::C_Widget	m_wgElemEnergy;
	gui::C_Label	m_lbElemEnergyTopic;
	gui::C_Label	m_lbElemEnergyResult;

	//////////////////////////////////////////////////////////
	/////	Mohs
	gui::C_Widget	m_wgElemMohs;
	gui::C_Label	m_lbElemMohsTopic;
	gui::C_Label	m_lbElemMohsResult;

	//////////////////////////////////////////////////////////
	/////	Xray
	gui::C_Widget	m_wgElemXray;
	gui::C_Label	m_lbElemXrayTopic;
	gui::C_Label	m_lbElemXrayResult;

	//////////////////////////////////////////////////////////
	/////	Melting
	gui::C_Widget	m_wgElemMelting;
	gui::C_Label	m_lbElemMeltingTopic;
	gui::C_Label	m_lbElemMeltingResult;
	//////////////////////////////////////////////////////////
	/////	Melting Energy
	gui::C_Widget	m_wgElemMeltingEnergy;
	gui::C_Label	m_lbElemMeltingEnergyTopic;
	gui::C_Label	m_lbElemMeltingEnergyResult;

	//////////////////////////////////////////////////////////
	/////	Refraction
	gui::C_Widget	m_wgElemRef;
	gui::C_Label	m_lbElemRefTopic;
	gui::C_Label	m_lbElemRefResult;

	//////////////////////////////////////////////////////////
	/////	Resistivity
	gui::C_Widget	m_wgElemRes;
	gui::C_Label	m_lbElemResTopic;
	gui::C_Label	m_lbElemResResult;


	///////////////////////////////////////////////////////////
	////	Amount settings
	gui::C_Widget	m_wgAmount;
	gui::C_Label	m_lbAmtTopic;
	gui::C_Label	m_lbAmtResult;
	gui::C_Widget	m_wgAmtResultAndButton;
	gui::C_Widget	m_wgAmtButton;
	gui::C_TextButton	m_tbMoreAmount;
	gui::C_TextButton	m_tbLessAmount;

	gui::C_RectButton	m_tbAddElem;
	gui::C_RectButton	m_tbDelElem;
	gui::C_RectButton	m_tbCreateElem;
	gui::C_RectButton	m_tbSaveElem;
	gui::C_RectButton	m_tbBack;
	int m_Amt;

	////////////////////////////////////////////////////////////
	/////	LIST WITH ADDED ELEMENTS
	gui::C_Widget	m_wgListAdded;
	gui::C_List		m_ltAdded;

	//selected item
	C_ChemicalElement *m_selectedElem;

	//////////////////////////////////////////////////////////////
	///// FUSION PROPERTIES
	//////////////////////////////////////////////////////////
	/////	GLYPH
	gui::C_Widget	m_wgFusGlyph;
	gui::C_Label	m_lbFusGlyphTopic;
	gui::C_LineEdit m_edFusGlyph;

	//////////////////////////////////////////////////////////
	/////	Name
	gui::C_Widget	m_wgFusName;
	gui::C_Label	m_lbFusNameTopic;
	gui::C_LineEdit m_edFusName;

	//////////////////////////////////////////////////////////
	/////	Weight
	gui::C_Widget	m_wgFusWeight;
	gui::C_Label	m_lbFusWeightTopic;
	gui::C_Label	m_lbFusWeightResult;

	//////////////////////////////////////////////////////////
	/////	Appereance
	gui::C_Widget	m_wgFusApp;
	gui::C_Label	m_lbFusAppTopic;
	gui::C_Label	m_lbFusAppResult;

	//////////////////////////////////////////////////////////
	/////	Energy
	gui::C_Widget	m_wgFusEnergy;
	gui::C_Label	m_lbFusEnergyTopic;
	gui::C_Label	m_lbFusEnergyResult;

	//////////////////////////////////////////////////////////
	/////	Mohs
	gui::C_Widget	m_wgFusMohs;
	gui::C_Label	m_lbFusMohsTopic;
	gui::C_Label	m_lbFusMohsResult;

	//////////////////////////////////////////////////////////
	/////	Xray
	gui::C_Widget	m_wgFusXray;
	gui::C_Label	m_lbFusXrayTopic;
	gui::C_Label	m_lbFusXrayResult;

	//////////////////////////////////////////////////////////
	/////	Melting
	gui::C_Widget	m_wgFusMelting;
	gui::C_Label	m_lbFusMeltingTopic;
	gui::C_Label	m_lbFusMeltingResult;
	//////////////////////////////////////////////////////////
	/////	Melting Energy
	gui::C_Widget	m_wgFusMeltingEnergy;
	gui::C_Label	m_lbFusMeltingEnergyTopic;
	gui::C_Label	m_lbFusMeltingEnergyResult;

	//////////////////////////////////////////////////////////
	/////	Refraction
	gui::C_Widget	m_wgFusRef;
	gui::C_Label	m_lbFusRefTopic;
	gui::C_Label	m_lbFusRefResult;

	//////////////////////////////////////////////////////////
	/////	Resistivity
	gui::C_Widget	m_wgFusRes;
	gui::C_Label	m_lbFusResTopic;
	gui::C_Label	m_lbFusResResult;

	//////////////////////////////////////////////////////////
	/////	Amount
	gui::C_Widget	m_wgFusAmt;
	gui::C_Label	m_lbFusAmtTopic;
	gui::C_Label	m_lbFusAmtResult;
public:
	C_GUI_FusionEditor();
	virtual ~C_GUI_FusionEditor();

	/////////////////////////////////////////////////////////////////////////////////
	//////	MAIN FUNCTION
	virtual void handleEvent(sf::Event e);
	virtual void render();
	virtual void update();

	void cmd_moreAmt();
	void cmd_lessAmt();
	void cmd_addElem();
	void cmd_delElem();
	void cmd_createElem();
	void cmd_saveElem();
	void cmd_back();
};

